package Structural_design_pattern.Decorator_Pattern.Example2;


//基本功能类,实现凯撒加密
public class SimpleCipher implements Cipher {
    public String Encrypt(String plainText) {
        String str = "";
        for(int i = 0; i < plainText.length(); i++) {
            char c = plainText.charAt(i);
            if(c>='a' && c<='z'){
                c+=6;
                if(c>'z') c-=26;
                if(c<'a') c+=26;
            }
            if(c>='A' && c<='Z'){
                c+=6;
                if(c>'Z') c-=26;
                if(c<'A') c+=26;
            }
            str += c;
        }
        return str;
    }
    
    
}
